#include "Roi.h"
#include "iostream"

Roi::Roi(){}


Roi::Roi(int x,int y, bool white)
{
    m_x = x;
    m_y = y;
    m_white = white;

}

char
Roi::tostring()
{
    return( m_white ? 'R' : 'r');
}

void
Roi::affiche()
{
    cout << "Roi: x=" << m_x << " y=" << m_y << " "
         << ( isWhite() ? "blanche" : "noire" ) << endl;

}

bool
Roi::mouvementvalide(Echiquier *e, int x, int y )
{
    if (Piece::mouvementvalide(e,x,y))
    {
        if((x-m_x == 1 || m_x-x == 1 || x==m_x)
           && (y-m_y==1 || m_y-y == 1 || y == m_y) )
        {
                if(e->presentm_blanc(x,y) || e->presentm_noir(x,y))
                {
                    affiche();
                    cout <<" en echec" << endl;
                    return false;
                }
            else
                return true;
        }
    }
    return false;
}


Roi::~Roi(){}
